#include <QtCore/QString>
#include <QtTest/QtTest>
#include "PersistentList.h"
#include "CjTypeWrapper.h"
#include <QList>
using namespace clojure_lang;

class PersistentListTests : public QObject
{
    Q_OBJECT
private:


public:
    PersistentListTests();

private Q_SLOTS:
    void OneArgCtorConstructsListOfOneElement();
    void ListCtorConstructsListOfSeveralElements();
};

PersistentListTests::PersistentListTests()
{

}

void PersistentListTests::OneArgCtorConstructsListOfOneElement()
{
    PersistentList *lst = new PersistentList(new CjTypeWrapper(QString("abc")));


    QVERIFY2(lst->first()->equals(new CjTypeWrapper("abc")), "First Matches");
    QVERIFY2(lst->next() == NULL, "Next is Null" );
    QVERIFY2(lst->count() == 1, "Count Matches");
}

void PersistentListTests::ListCtorConstructsListOfSeveralElements()
{
    QList<CjObject *> *qlst = new QList<CjObject *>();
    qlst->append(new CjTypeWrapper(1));
    qlst->append(new CjTypeWrapper("abc"));
    qlst->append(new CjTypeWrapper(2));
    qlst->append(new CjTypeWrapper("def"));

    IPersistentList *lst = PersistentList::create(qlst);
    /*ISeq *s = lst->seq();
    QVERIFY2(s->count() == 4, "Count = 4");
    QVERIFY2(s->first()->equals(new CjTypeWrapper(1)), "First Matches");
    QVERIFY2(s->next()->first()->equals(new CjTypeWrapper("abc")), "Seccond Matches");
    QVERIFY2(s->next()->next()->first()->equals(new CjTypeWrapper(2)), "Third Matches");
    QVERIFY2(s->next()->next()->next()->first()->equals(new CjTypeWrapper("def")), "Fourth Matches");
    QVERIFY2(s->next()->next()->next()->next()->first()== NULL, "Fifth is NULL");
    */
}

QTEST_APPLESS_MAIN(PersistentListTests);

#include "PersistentMap.moc"
